#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
    void duplicateZeros(vector<int>& arr)
    {
        int i = 0;
        while (i < arr.size())
        {
            //cout<<"i="<<i<<endl;
            if (arr[i] == 0)
            {
                int j = arr.size() - 1;
                while (j > i + 1)
                {
                    //cout<<"j="<<j<<"|";
                    arr[j] = arr[j - 1];
                    --j;
                }
                if (i + 1 < arr.size())
                    arr[i + 1] = 0;
                ++i;
                //for(auto a:arr) cout<<a<<" ";
                //cout<<endl;
            }
            //cout<<endl;
            ++i;
        }
    }
};